console.log('周边资源-按钮', $event);
const $form = this.getApiPage().getApiWidgetByAliasName('judge-content').widgetObj;
const linkage = this.getApiPage().getApiWidgetByAliasName('周边资源图表');
const $distance = this.getApiPage().getApiWidgetByAliasName('周边资源范围选择');
const emergency_context = this.getApiPage().getApiWidgetsByClassName('emergency_context');
const wuzi = this.pageObj.getApiWidgetByAliasName('物资总数');
const pinzhong = this.pageObj.getApiWidgetByAliasName('品种数量');
const kucun = this.pageObj.getApiWidgetByAliasName('库存总数');
const enums = this.getApiPage().getVariables();
const prefix = enums.find(v => v.name === "environmentType")?.value;
const recordId = enums.find(item => item.name === 'event_record_id')?.value;
const recordType = enums.find(item => item.name === 'event_record_type')?.value;
const { dataSource } = $form._option;
const url = `/${prefix}SummaryAssessmentSV/eventRecord/emergencyGoodsStatistics`
const requestGet = (url) => {
    return fetch(url, { headers: { "Content-Type": "application/json" } }).then(res => res.json())
};

this.getApiPage().setVariables([{ name: 'linkage_type', value: $event }]);

// member_linkage emergency_supplies
if ($event === 'emergency_supplies') {
    linkage?.hideWidget();
    $distance?.hideWidget();
    emergency_context?.forEach(function(widget) {
        widget.showWidget();
    });

    requestGet(`${url}?eventId=${recordId}&type=${recordType}`).then(({ result, success } = {}) => {
        if (success && result) {
            $(wuzi.__box).find('.emergency-context').text(result.goodsTotalCount);
            $(pinzhong.__box).find('.emergency-context').text(result.goodsTypeCount);
            $(kucun.__box).find('.emergency-context').text(result.warehouseTotalCapacity);
        }
        console.log('emergencyGoodsStatistics: => ', { result, success });
    });
} else {
    linkage?.showWidget();
    $distance?.showWidget();
    emergency_context?.forEach(function(widget) {
        widget.hideWidget();
    });
}
